from Interface.litemall_po2.apis.base_api import BaseApi


class Goods(BaseApi):

    def create(self, goods_data):
        url = "admin/goods/create"
        # r = self.send("post", url, json=goods_data, headers={"X-Litemall-Admin-Token": self.token})
        r = self.send("post", url, json=goods_data)

        return r

    def list(self, goods_name, order="desc", sort="add_time"):
        # 自己编写的接口对应的方法，应该和接口本身的逻辑相关
        goods_list_url = "admin/goods/list"
        goods_data = {"name": goods_name, "order": order, "sort": sort}
        r = self.send("get", goods_list_url,params=goods_data)

        return r

    def detail(self, goods_id):
        goods_detail_url = "admin/goods/detail"
        r = self.send("get", goods_detail_url,params={"id": goods_id})

        return r

    def delete(self,goods_id):
        url = "admin/goods/delete"
        r = self.send("post", url, json={"id": goods_id})

        return r
